 var currentObj;
 function submitAddOperation(){
 	// Ajax ADD Operation info
	/*-------------function begin---------------------------*/	
 	var title    = document.getElementById("_title").value ;
 	var identify = document.getElementById("_identify").value;
 	var htmlStr  = document.getElementById("_htmlStr").value;
 	var comment  = document.getElementById("_comment").value;
 	
	$.ajax({
			type: "post",
	    	dataType:"xml",
			"url" : "AjaxAMOperationInfoServlet",
			//提交的数�
			data: {_operationId:0,_title:title,_identify:identify,_htmlStr:htmlStr,_comment:comment},
			beforeSend: function(XMLHttpRequest){
            },
            success: function(data, textStatus){
                 var result    =  $(data).find("result").text();
                 if( result == "true"){
                 	addOpreationContainer(data);
                 	cleanAddContanter();
                 	$("#opNoticeSpan").html("操作成功！");
   		 	 		setTimeout(function(){$("#opNoticeSpan").html("")},3000);
                 }else{
                 	 fileNotice();
                 }
		    },
			complete: function(XMLHttpRequest, textStatus){
			},
			error: function(){
				
			}
	})
	/*-------------function end  ---------------------------*/
 }
 
 function addOpreationContainer(xmlData){
    var operationId = $(xmlData).find("operationId").text();
    var title       = $(xmlData).find("title").text();
    $("#ListDiv_cleanfloat").remove();
 	$("#OperationListDiv").append(
 	"<div style='float:left;width:200px; margin:5px;padding-top:5px; border:1px dotted #CCC;'>"
       +"<div style='float:left;width:150px;'>"+title+"</div>"
       +"<div style='float:left;width:25px;cursor:pointer;'><img onclick='EditOperation("+operationId+",this)' class='buttonBcImg' width='20' src='./images/edit.jpg' /></div>"
       +"<div style='float:left;width:25px;cursor:pointer;'><img onclick='DeleteOperation("+operationId+",this)' class='buttonBcImg' width='20' src='./images/delete.png' /></div>"
       +"<div style='clear:both' ></div>"
  	+"</div><div id='ListDiv_cleanfloat' style='clear:both' ></div>"
 	);
 }
 function cleanAddContanter(){
 	document.getElementById("_title").value = "";
 	document.getElementById("_identify").value = "";
 	document.getElementById("_htmlStr").value  = "";
 	document.getElementById("_comment").value  = "";
 }
 
 function EditOperation(operationId,obj){
 	currentObj = obj;
	// Ajax get OPeration  Info
	/*-------------function begin---------------------------*/	
	$.ajax({
			type: "post",
	    	dataType:"xml",
			"url" : "AjaxGetOperationServlet",
			//提交的数�
			data: {_operationId:operationId},
			beforeSend: function(XMLHttpRequest){
            },
            success: function(data, textStatus){
                 var result    =  $(data).find("result").text();
                 if( result == "true"){
                 	LoadRoleInfo(data);
                 	showEditOperation();
                 }
		    },
			complete: function(XMLHttpRequest, textStatus){
			},
			error: function(){
				
			}
	})
	/*-------------function end  ---------------------------*/
 }
 
 function LoadRoleInfo(xmlData){
 	var operationId   = $(xmlData).find("operationId").text();
 	var title         = $(xmlData).find("title").text();
 	var identify      = $(xmlData).find("identify").text();
 	var htmlStr       = $(xmlData).find("htmlStr").text();
 	var comment       = $(xmlData).find("comment").text();
 	document.getElementById("E_operationId").value   = operationId;
 	document.getElementById("E_title").value         = title;
 	document.getElementById("E_identify").value      = identify;
 	document.getElementById("E_htmlStr").value       = htmlStr;
 	document.getElementById("E_comment").value       = comment;
 }
 
 function showEditOperation(){
 	var screenwidth, screenheight, mytop, getPosLeft, getPosTop          
	screenwidth     = $(window).width();          
	screenheight    = $(window).height();                    //获取滚动条距顶部的偏�   
	mytop           = $(document).scrollTop();               //计算弹出层的left  
	var myheight    = $("#OperationEditContainer").height();
	var mywidth     = $("#OperationEditContainer").width(); 
	getPosLeft      = (screenwidth - mywidth)/2;             //计算弹出层的top        
	getPosTop       = (screenheight - myheight)/2 -30; 
	$("#OperationEditContainer").css({ "left": getPosLeft, "top": getPosTop });
	
	showCover()
	$("#OperationEditContainer").css("display", "block");
	$("#EditOperation_close").click( function(){  
	     $("#OperationEditContainer").css({"display" : "none"});
	     hideCover();
	});
 }
 function hidenEditOperation(){
 	$("#OperationEditContainer").css({"display" : "none"});
	hideCover();
 }
 
 function submitEditOperation(){
 	$(":input").css("border-color","");
     if($("#E_title").val().trim().length == 0){
        $("#E_title").css("border-color","red");
        alert("Title 不能为空！");
        return;
     }
     if($("#E_identify").val().trim().length == 0){
     	$("#E_identify").css("border-color","red");
        alert("Identify 不能为空！");
        return;
     }
 	// Ajax Modify Role info
	/*-------------function begin---------------------------*/	
	var operationId   = document.getElementById("E_operationId").value;
 	var title         = document.getElementById("E_title").value ;
 	var identify      = document.getElementById("E_identify").value;
 	var htmlStr       = document.getElementById("E_htmlStr").value;
 	var comment       = document.getElementById("E_comment").value;
 	//alert(roleId+","+title+","+identify+","+comment);
	$.ajax({
			type: "post",
	    	dataType:"xml",
			"url" : "AjaxAMOperationInfoServlet",
			//提交的数�
			data: {_operationId:operationId,_title:title,_identify:identify,_htmlStr:htmlStr,_comment:comment},
			beforeSend: function(XMLHttpRequest){
            },
            success: function(data, textStatus){
                 var result    =  $(data).find("result").text();
                 if( result == "true"){
                 	var obj = $(currentObj).parent().parent();  
                 	$((obj.children())[0]).html(title);
                 	$("#opNoticeSpan").html("操作成功！");
   		 	 		setTimeout(function(){$("#opNoticeSpan").html("")},3000);
                 }else{
                 	failNotice();
                 }
                  hidenEditOperation();
		    },
			complete: function(XMLHttpRequest, textStatus){
			},
			error: function(){
				
			}
	})
	/*-------------function end  ---------------------------*/
 }
 
 function failNotice(){
 	$("#opNoticeSpan").html("操作失败，存在Identify相同操作.");
   	setTimeout(function(){$("#opNoticeSpan").html("")},3000);
 }
 
 function DeleteOperation(operationId,obj){
 	if(!confirm("确定要删除该操作吗?")){
	 	return 
	 } 
 	// Ajax get Role  Info
	/*-------------function begin---------------------------*/	
	$.ajax({
			type: "post",
	    	dataType:"xml",
			"url" : "AjaxDeletetOperationServlet",
			//提交的数�
			data: {_operationId:operationId},
			beforeSend: function(XMLHttpRequest){
            },
            success: function(data, textStatus){
                 var result    =  $(data).find("result").text();
                 if( result == "true"){
                 	$(obj).parent().parent().remove();
                 }
		    },
			complete: function(XMLHttpRequest, textStatus){
			},
			error: function(){
				
			}
	})
	/*-------------function end  ---------------------------*/
 }